﻿using System;

namespace StrategyPattern;

// 所得税计算策略
public interface ITaxStrategy
{
    double CalculateTax(double income);
}

// 个人所得税
public class PersonalTaxStrategy : ITaxStrategy
{
    public double CalculateTax(double income) => income - 3500 > 0 ? (income - 3500) * 0.045 : 0.0;
}

// 企业所得税
public class EnterpriseTaxStrategy : ITaxStrategy
{
    public double CalculateTax(double income) => income * 0.12;
}

public class InterestOperation(ITaxStrategy strategy)
{
    public double GetTax(double income) => strategy.CalculateTax(income);
}

public static class Program
{
    public static void Main()
    {
        // 个人所得税方式
        var operation = new InterestOperation(new PersonalTaxStrategy());
        Console.WriteLine($"个人支付的税为：{operation.GetTax(8000.00)}");

        // 企业所得税
        operation = new InterestOperation(new EnterpriseTaxStrategy());
        Console.WriteLine($"企业支付的税为：{operation.GetTax(8000.00)}");
    }
}